/***************************************************************************
 *   Copyright (C) 2008 by Goliash   *
 *   goliash@goliash.net   *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
 ***************************************************************************/
#ifndef FILE_H
#define FILE_H
#include <QString>
#include <QDateTime>
#include <QList>
#include "picture.h"
#include "audio.h"
#include "document.h"

class File
{
public:
	File();
	File(QString name);

	// size formats
	static const int ByteF = 1;
	static const int KiloF = 2;
	static const int MegaF = 3;
	static const int DynamicF = 4;
	// date format
	static const int StandardDateF = 1;

	// file types ( it has to be the same like in table types - MainWindow::newDb() )
	static const int Folder = 1;
	static const int JPEG = 2;
	static const int Text = 3;
	static const int Archive = 4;
	static const int Unknown = 5;
	static const int Test = 6;
	static const int PNG = 7;
	static const int AudioContent = 8;
	static const int PDF = 9;

	bool isFolder();
	void setFolder(bool folder);
	void setRights(bool read, bool write, bool exec);
	void setOwners(QString owner, QString group);
	void setDates(QDateTime created, QDateTime modified);
	void setSize(quint64 size);
	void setType(int type);
	void setContent(QByteArray *bytes);
	void setAllContent(bool all);
	
	QString getRights();
	QDateTime getCreatedDate();
	QDateTime getModifiedDate();
	quint64 getSize();
	int getType();
	QByteArray *getContent();
	bool isAllContent();

	bool additionalImageInfo();
	Picture *getPicture();
	static QString getFormattedSize(quint64 size, const int format);
	static QString getFormattedDate(QString date, const int format);

	bool additionalAudioInfo();
	Audio *getAudio();

	bool additionalDocumentInfo();
	Document *getDocument();

	QString toString();
	QString getName();
	QList<File *> children;

private:
	qint64 size;
	bool folder;
	QDateTime creation_time;
	QString name;
	QString rights;
	QString owner;
	QString group;
	int type;
	QByteArray *content;
	bool all_content;
	//QByteArray thumbnail;
	QDateTime created;
	QDateTime modified;
	Picture *pict;
	Audio *audio;
	Document *document;
};

#endif

